//-----------------------------------------------------------------------
// <copyright file="PresentServiceBase.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using Pyco;
using Pyco.Diagnostics;
using Pyco.Data;
using BirthdayReminder.Entities;
using BirthdayReminder.Data;
    
namespace BirthdayReminder.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class PresentServiceBase
    {
        #region PresentServiceBase

        public static void CreatePresent(Present present)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                presentDAO.CreatePresent(present);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessCreatePresentException, ex);
            }
        }

        public static void UpdatePresent(Present present)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                presentDAO.UpdatePresent(present);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessUpdatePresentException, ex);
            }
        }        

        public static void DeletePresent(int presentId)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                presentDAO.DeletePresent(presentId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessDeletePresentException, ex);
            }
        }
		
        public static Present GetPresent(int presentId)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                return presentDAO.GetPresent(presentId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetPresentException, ex);
            }
        }                
		
        public static PresentCollection GetPresentList(PresentColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                return presentDAO.GetPresentList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetPresentListException, ex);
            }
        }        

        public static PresentCollection GetPresentList(PresentColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                return presentDAO.GetPresentList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetPresentListException, ex);
            }
        }        
		
        public static PresentCollection GetPresentsListByReceiverId(int receiverId, PresentColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                PresentDAO presentDAO = new PresentDAO();
                return presentDAO.GetPresentsListByReceiverId(receiverId, orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetPresentListException, ex);
            }
        }        
		
        
		
        #endregion
    }
}